package com.asset.admin.system.tradingtype.form;

import com.asset.admin.dao.entity.TradingTypeEntity;

import java.util.Map;

/**
 * <p>
 * 交易类型form
 * </p>
 *
 * @author 牧之
 * @date 2024/2/19 15:50
 */
public class TradingTypeForm {

    //交易类型id
    private Long id;

    //交易类型名称
    private String name;

    private String type;

    private String createName; // 更新者
    private String createTime; // 创建时间
    private String updateTime; // 修改时间
    //交易方向code


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public static TradingTypeForm convertEntity2Form(TradingTypeEntity entity, Map<Long, String> userIdNameMap){
        if(entity == null){
            return null;
        }
        TradingTypeForm form = new TradingTypeForm();
        form.setId(entity.getId());
        form.setName(entity.getName());
        form.setType(entity.getType());
        form.setCreateName(userIdNameMap == null ? "" : userIdNameMap.get(entity.getCreator()));
        form.setCreateTime(entity.getCreateTime());
        form.setUpdateTime(entity.getUpdateTime());
        return form;
    }

    public static TradingTypeEntity convertForm2Entity(TradingTypeForm form){
        TradingTypeEntity entity = new TradingTypeEntity();
        entity.setId(form.getId());
        entity.setName(form.getName());
        entity.setType(form.getType());
        entity.setCreateTime(form.getCreateTime());
        entity.setUpdateTime(form.getUpdateTime());
        return entity;
    }
}
